package com.ruoyi.system.domain.base;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.system.domain.equipment.EquipmentType;
import lombok.Data;


import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author ruoyi
 */
@Data
public class TreeShop implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    /** 节点编码 */
    private String code;

    /** 节点类型 */
    private Integer type;


    /** 设备类型id */
    private Long typeId;

    /** 设备类型名称 */
    private String typeName;

    /** 设备类型编码 */
    private String typeCode;
    /** 设备类型备注 */
    private String remarks;
    /** 台套数 */
    private Double setNumber;


    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeShop> children;

    public TreeShop()
    {

    }


    public TreeShop(BaseShop shop)
    {
        this.id = shop.getShopId();
        this.label = shop.getShopName();
        this.type = shop.getShopType();
        this.typeCode = shop.getShopCode();
        this.children = shop.getChildren().stream().map(TreeShop::new).collect(Collectors.toList());
    }

    public TreeShop(BaseBomInfo info)
    {
        this.id = info.getId();
        this.code = info.getMaterialCode();
        this.label = info.getBomInfoName();
        this.setNumber = info.getSetNumber();
        this.children = info.getChildren().stream().map(TreeShop::new).collect(Collectors.toList());
    }

    public TreeShop(EquipmentType info)
    {
        this.typeId = info.getTypeId();
        this.typeName = info.getTypeName();
        this.typeCode = info.getTypeCode();
        this.remarks = info.getRemarks();
        this.children = info.getChildren().stream().map(TreeShop::new).collect(Collectors.toList());
    }


}
